//
//  HJNotMatch.m
//  project
//
//  Created by jc on 2019/4/29.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJNotMatch.h"
#import "YFJourneyModel.h"
#import "HJChatRoomVC.h"

@interface HJNotMatch ()

@property (weak, nonatomic) IBOutlet UIView *BgView;
@property (weak, nonatomic) IBOutlet UIImageView *juurneyImage;
@property (weak, nonatomic) IBOutlet UILabel *journeyTiltle;
@property (weak, nonatomic) IBOutlet UILabel *create_time;
@property (weak, nonatomic) IBOutlet UILabel *jouneyTime;
@property (weak, nonatomic) IBOutlet UILabel *startLabel;
@property (weak, nonatomic) IBOutlet UILabel *endLabel;
@property (strong, nonatomic) UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIButton *journeyBtn;

@property (nonatomic,strong) YFRecordModel * recordModel;



@end

//static NSString * const identifier = @"userCell";

@implementation HJNotMatch

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
    [self.BgView rounded:UIRectCornerAllCorners radius:12];
    [self.journeyBtn rounded:UIRectCornerAllCorners radius:self.journeyBtn.width*0.5];
//    self.collectionView.delegate = self;
//    self.collectionView.dataSource = self;
    
    self.journeyTiltle.font = PingfangMedium15;
    self.create_time.font = [UIFont fontWithName:PingFangSC_Medium size:SCREEN_WIDTH /375*12];
    
    @weakify(self)
    [[self.journeyBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self)
        UIButton * btn = (UIButton *)x;
        if ([btn.titleLabel.text isEqualToString:@"乐见"]) {
            self.encounterBlock(self.recordModel.tripModel.journey_id);
        }else {
            self.ChatClickedBlock(self.recordModel);
        }
    }];
}

-(void)setType:(NotMatchType)type {
    _type = type;
    if (type == notMatch) {
        [self.journeyBtn setTitle:@"乐见" forState:0];
    }else if (type == matched) {
        [self.journeyBtn setTitle:@"去聊" forState:0];
    }else {
        [self.journeyBtn setTitle:@"去聊" forState:0];
    }
}

-(void)loadMatchCellDataSource:(YFRecordModel *)model {
    self.recordModel = model;
    // 行程标题
    self.journeyTiltle.text = model.tripModel.title;
    
    // 创建时间
    self.create_time.text =  model.tripModel.createTime;
    
    // 起点名称
    self.startLabel.text = model.tripModel.startTxt;
    
    // 出行方式
    self.juurneyImage.image = model.tripModel.wayImage;
    
    // 终点名称
    self.endLabel.text = model.tripModel.dstTxt;
    
    // 出行日期和时间
    self.jouneyTime.text = [NSString stringWithFormat:@"%@ %@",model.tripModel.journeyDate,model.tripModel.journeyTime];
    // 行程状态
//    self.type = model.tripModel.tripStatus.integerValue;
    
}

//-(UICollectionView *)collectionView {
//    if (!_collectionView) {
//        UICollectionViewFlowLayout *layout =[[UICollectionViewFlowLayout alloc]init];
//        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
//
//        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-48-12, 44) collectionViewLayout:layout];
//        _collectionView.delegate = self;
//        _collectionView.dataSource = self;
//        _collectionView.showsHorizontalScrollIndicator = NO;
//        _collectionView.backgroundColor = [UIColor clearColor];
//        [_collectionView registerClass:[HJUserCollectionCell class] forCellWithReuseIdentifier:identifier];
//        [self.subListView addSubview:_collectionView];
//    }
//    return _collectionView;
//}
//-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
//    return self.recordModel.userList.count;
//}
//
//-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
//    HJUserCollectionCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
//    [cell.avatorImageView sd_setImageWithURL:self.recordModel.userList[indexPath.row].user.avatarURL];
//    return cell;
//}
//
//- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
//    return UIEdgeInsetsMake(2, 2, 2, 2);
//}
//
//- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
//    return CGSizeMake(40, 40);
//}
//
//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
//    return 10;
//}
//
//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
//    return 0;
//}
//
//@end


//@implementation HJUserCollectionCell
//
//- (instancetype)initWithFrame:(CGRect)frame {
//    if (self = [super initWithFrame:frame]) {
//        [self initSubViews];
//    }
//    return self;
//}
//
//
//-(void)initSubViews {
//    UIImageView * avatorImageView = [UIImageView new];
//    self.avatorImageView = avatorImageView;
//    [self.contentView addSubview:avatorImageView];
//}
//
//-(void)layoutSubviews {
//    [super layoutSubviews];
//    self.avatorImageView.frame = self.contentView.bounds;
//    [self.avatorImageView rounded:UIRectCornerAllCorners radius:self.avatorImageView.height/2 borderColor:[UIColor blackColor] borderWidth:1];
//}
//
@end
